<template>
	<view class="onAccountCheck">
		
		<!-- 订单列表 -->
		<order-list :list="orderList" :dx="dx" :isOrder="isOrder" ></order-list>
	</view>
</template>

<script>
	const util = require("../../utils/util.js");
	//获取应用实例
	const api = require("../../config/api.js"); 
	import orderList from "../../components/orderList/orderList";
	
	export default { 
		data() {
			return {
				page:1,
				orderList:[],
				// 没有更多数据
				dx:false,
				isOrder:true
			}
		},
		components: {
		  orderList
		},
		onLoad(){
			
			this.getOrderList();
		},
		
		onShow(){
			this.page=1
			this.getOrderList()
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1
			console.log(this.page)
		    this.getOrderList()
			
		},
		// 上拉加载
		onReachBottom(){
			uni.showNavigationBarLoading();//显示加载动画
			this.page++;
			util.request(api.businessOrderList+'?page='+this.page+'&size=20', {
				status:-1,
				prePayOrder:1
			}, 'POST').then(res => {
				console.log(res)
				if(res.error==0){
					if(this.page>1){
						 if(res.data.data.length==0){
						 	if(this.page>1){
						 		uni.hideNavigationBarLoading();//关闭加载动画
								this.dx=true
							}
						}else{
							this.orderList = [...this.orderList,...res.data.data]
						}
						
					}
					uni.hideNavigationBarLoading();//关闭加载动画
				}
			})
		},
		methods: {
			table(index){
				this.active = index;
				this.dx = false;
				this.getOrderList()
			},
			search(){
				uni.navigateTo({
					url:"/pages/search/search"
				})
			},
			black(){
				uni.navigateBack()
			},
			getOrderList(){
				// 获取订单列表
				console.log(this.page)
				util.request(api.businessOrderList+'?page='+this.page+'&size=20', {
					status:-1
				}, 'POST').then(res => {
					console.log(res)
					if(res.error==0){
						this.orderList = res.data.data
					}
					uni.stopPullDownRefresh()
				})
			}
		}
	}
</script>

<style>
	@import url("./onAccountCheck.css");
</style>
